package com.czl.module_storehouse.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;


import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.czl.base.data.bean.tengyun.BorrowBean;
import com.czl.module_storehouse.R;
import com.czl.module_storehouse.bean.RemandBean;
import com.lihang.ShadowLayout;

import java.util.List;

/**
 * @author xubin
 */
public class RemandHomeNeedBorrowAdapter extends BaseQuickAdapter<RemandBean, BaseViewHolder> {

    private boolean visibleNum;

    public RemandHomeNeedBorrowAdapter(int layoutResId, @Nullable List<RemandBean> data) {
        super(layoutResId, data);
    }

    public RemandHomeNeedBorrowAdapter(int layoutResId, @Nullable List<RemandBean> data, boolean visibleNum) {
        super(layoutResId, data);
        this.visibleNum = visibleNum;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, RemandBean item) {
        BorrowBean borrowBean = item.getBorrowBean();
        if (borrowBean != null) {
            helper.setText(R.id.tv_title, borrowBean.getBorrowName())
                    .setText(R.id.tv_date, borrowBean.getBorrowDate())
                    .setText(R.id.tv_code, borrowBean.getBorrowCode("借用单："))
                    .setText(R.id.tv_mo_date, "拟还日期：" + borrowBean.getMoReturnDate())
                    .setText(R.id.tv_department, "借用部门：" + borrowBean.getBorrowPersonDepartment())
                    .setText(R.id.tv_desc, "借用说明：" + borrowBean.getApplyComment())
                    .setVisible(R.id.tv_remand_total, borrowBean.isRemandVisableNum(visibleNum))
                    .setText(R.id.tv_remand_total, borrowBean.getRemandTotalTextNum("已还"));
            ShadowLayout shadowLayout = helper.getView(R.id.shadowLayout);
            shadowLayout.setShadowHiddenBottom(helper.getLayoutPosition() != getDefItemCount() - 1);
        }
    }
}
